﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AddRoleModules.ascx.cs"
    Inherits="Member_Control_AddRoleModules" %>
<style type="text/css">
    .style1
    {
        height: 36px;
    }
</style>
<h2>
    Thiết lập quyền :
    <%= Request["r"] %>
</h2>
<div style="margin-bottom: 15px">
    Nhóm module
    <asp:DropDownList ID="ddlModules" runat="server" AppendDataBoundItems="true" Width="250px">
        <asp:ListItem Value="">------------------ Chọn module -----------------</asp:ListItem>
    </asp:DropDownList>
    <span class="button fix">
        <asp:Button ID="btnUpdate" runat="server" Text="Cập nhật" OnClick="btnUpdate_Click" />
        <span></span></span>
</div>
<table width="100%" class="grid">
    <tr>
        <th>
            Chức năng
        </th>
        <th width="150px">
            Phòng ban
        </th>
        <th width="40px">
            <img src="/images/button/view.png" alt="Xem" title="Xem" />
        </th>
        <th width="40px">
            <img src="/images/button/view.png" alt="Xem" title="Xem của người khác" />
        </th>
        <th width="40px">
            <img src="/images/button/add.png" width="20px" height="20px" alt="Thêm" title="Thêm" />
        </th>
        <th width="40px">
            <img src="/images/button/edit.png" alt="Sửa" title="Sửa" />
        </th>
        <th width="40px">
            <img src="/images/button/edit-to.png" alt="Sửa" title="Sửa thông tin người khác" />
        </th>
        <th width="40px">
            <img src="/images/button/delete.png" width="20px" height="20px" alt="Xóa" title="Xóa" />
        </th>
        <th width="40px">
            <img src="/images/button/del-to.png" width="20px" height="20px" alt="Xóa" title="Xóa thông tin người khác" />
        </th>
        <th width="40px">
            <img src="/images/button/accept.png" width="20px" height="20px" alt="Enable" title="Enable" />
        </th>
        <%--<th width="40px">
            <img src="/images/button/block.png" width="20px" height="20px" alt="" title="Disable" />
        </th>--%>
        <th width="40px">
        </th>
        <th width="40px">
        </th>
    </tr>
    <asp:Repeater ID="repSetRole" runat="server" 
        OnItemCommand="repSetRole_ItemCommand" 
        onitemdatabound="repSetRole_ItemDataBound">
        <ItemTemplate>
            <tr>
                <td>
                    <%# Eval("ModName") %>
                    <asp:HiddenField ID="hidRoleId" runat="server" Value='<%# Eval("RoleId") %>' />
                    <asp:HiddenField ID="hidModCode" runat="server" Value='<%# Eval("ModCode") %>' />
                </td>
                <td align="center">
                    <asp:DropDownList ID="ddlDepart" runat="server" AppendDataBoundItems="true" Width="120px" DataSource="<%# tblDepart %>" DataTextField="DepartName" DataValueField="Id">
                        <asp:ListItem Value="00000000-0000-0000-0000-000000000000">Chọn phòng ban</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkShow" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsShow")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkShowToUser" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsShowToUser")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkAdd" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsAdd")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkEdit" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsEdit")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkEditToUser" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsEditToUser")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkDelete" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsDelete")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkDeleteToUser" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsDeleteToUser")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkEnable" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsEnable")) %>'
                        CssClass='<%# "chk-" + Container.ItemIndex.ToString() %>' />
                </td>
                <td align="center">
                    <asp:CheckBox ID="chkIsAll" runat="server" Checked='<%# Convert.ToBoolean(Eval("IsAll")) %>'
                        CssClass='chk' index="<%# Container.ItemIndex %>" />
                </td>
                <td align="center">
                    <asp:LinkButton ID="LinkButton7" runat="server" CommandName="del" CommandArgument='<%# Eval("Id").ToString()%>'
                        OnClientClick="return confirm('Xác nhận xóa?')" ValidationGroup="set">
                            <img src='/images/button/delete.png'/>
                    </asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>
</table>

<script type="text/javascript">
    $(document).ready(function(){
        $("select[id*='ddlModules']").change(function(){
            var role = $.url.param('r');
            window.location = "/Member/RoleModules.aspx?r=" + role + "&m=" + $(this).val();
        });
        
        $(".chk").click(function(){
            var checked = $("input", $(this)).is(':checked');
            $('.chk-' + $(this).attr('index')).each(function(){
                $('input',$(this)).attr('checked', checked);
            });
        });
    });
</script>

